import axiosRequests from "@/api/axiosRequests.js";
import mockRequests from "@/api/mockRequests";


// ---------- ---------- ---------- MockJS 模拟数据 ---------- ---------- ----------


export const categoryJson = function () {
    return mockRequests({
        method: 'GET',
        url: '/category'
    });
};

export const bannerJson = function () {
    return mockRequests({
        url: '/banner',
        method: 'GET'
    });
};

export const floorJson = function () {
    return mockRequests({
        url: '/floor',
        method: 'GET'
    });
};


// ---------- ---------- ---------- Axios 后台数据 ---------- ---------- ----------


// ---------- SearchView.vue 商品搜索页面接口 ----------

export const searchJson = function (data) {
    return axiosRequests({
        url: '/list',
        method: 'POST',
        data: data
    });
};

// ---------- DetailView.vue 商品详情页面接口 ----------

export const reqDetailList = (skuId) => {
    return axiosRequests({
        url: `/item/${skuId}`,
        method: 'GET'
    });
};

export const reqAddOrUpdateCart = (skuId, skuNum) => axiosRequests({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: 'post'
});

// ---------- CartView.vue 购物车页面接口 ----------

export const reqShopCart = () => {
    return axiosRequests({
        url: '/cart/cartList',
        method: 'GET'
    });
};

export const reqDeleteCart = (skuId) => axiosRequests({
    url: `/cart/deleteCart/${skuId}`,
    method: 'DELETE'
});

export const reqUpdateChecked = (skuId, isChecked) => axiosRequests({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'GET'
});

// ---------- RegisterView.vue 注册页面接口 ----------

export const reqGetCode = (phone) => {
    return axiosRequests({
        url: `/user/passport/sendCode/${phone}`,
        method: 'GET'
    });
};

export const reqRegister = (data) => {
    return axiosRequests({
        url: '/user/passport/register',
        method: 'post',
        data: data
    });
};

// ---------- LoginView.vue 登录页面接口 ----------

export const reqUserLogin = (data) => {
    return axiosRequests({
        url: '/user/passport/login',
        method: 'post',
        data: data
    });
};

// ---------- @/router/index.js 前置守卫接口 ----------

export const reqUserInfo = () => {
    return axiosRequests({
        url: '/user/passport/auth/getUserInfo',
        method: 'GET'
    });
};

export const reqUserLogout = () => axiosRequests({
    url: `/user/passport/logout`,
    method: 'GET'
});

// ---------- TradeView.vue 交易页面接口 ----------

export const reqAddressInfo = () => axiosRequests({
    url: `/user/userAddress/auth/findUserAddressList`,
    method: 'GET'
});

export const reqShopInfo = () => axiosRequests({
    url: `/order/auth/trade`,
    method: 'GET'
});

export const reqSubmitOrder = (tradeNo, data) => axiosRequests({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: 'post',
    data: data
});

// ---------- PayView.vue 支付页面接口 ----------

export const reqPayInfo = (orderId) => axiosRequests({
    url: `/payment/weixin/createNative/${orderId}`,
    method: 'GET'
});

export const reqPayResult = (orderId) => axiosRequests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'GET'
});

// ---------- CenterView.vue 订单中心页面接口 ----------

export const reqMyOrderList = (page, limit) => axiosRequests({
    url: `/order/auth/${page}/${limit}`,
    method: 'GET'
});

// 这货还缺了个订单删除接口removeOrderById(orderId)



